//新增/编辑投标

<template>
  <div class="add_edit_bid">
    <!-- ===================================================== -->
    <!-- 表单 -->
    <el-form
      :inline="true"
      :model="bid_add_data"
      class="addBid"
      label-width="250px"
    >
      <!-- 添加投标信息 -->
      <el-form-item label="项目名称:">
        <el-input
          class="project_name"
          v-model="bid_add_data.name"
          placeholder="请输入"
          style="width: 200px"
        ></el-input>
      </el-form-item>
      <!-- =========== -->
      <el-form-item label="所在地区:">
        <el-select
          class="project_area"
          v-model="bid_add_data.area"
          placeholder="请选择"
          style="width: 200px"
          :disabled="true"
        >
          <el-option
            v-for="item in options_project_area"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- =========== -->
      <el-form-item label=" 开发商名称:">
        <el-input
          class="project_developers"
          v-model="bid_add_data.kai_fa_name"
          placeholder="请输入"
          style="width: 200px"
        ></el-input>
      </el-form-item>
      <!-- =========== -->
      <el-form-item label="投标开始日期:">
        <el-select
          class="create_date"
          v-model="bid_add_data.begin_date"
          placeholder="请选择"
          style="width: 200px"
          :disabled="true"
        >
          <el-option
            v-for="item in option_create_date"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- =========== -->
      <el-form-item label="投标结束日期:">
        <el-select
          class="end_date"
          v-model="bid_add_data.end_date"
          placeholder="请选择"
          style="width: 200px"
          :disabled="true"
        >
          <el-option
            v-for="item in option_end_date"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!-- =========== -->
      <el-form-item label="保证金是否缴纳:">
        <el-switch
          v-model="bid_add_data.pay_money"
          :active-value="1"
          :inactive-value="0"
          active-color="#13ce66"
          inactive-color="#ff4949"
          style="width: 200px"
        ></el-switch>
      </el-form-item>
    </el-form>

    <!-- 成员管理 -->
    <div class="member_management">
      <el-button type="success" class="add_btn">新增成员:</el-button>
      <sl-table
        name="sl-table1"
        :tableData="member_add_tableData"
        :tableKey="member_add_tableKey"
      ></sl-table>
    </div>

    <!-- 工作计划 -->
    <div class="work_plan">
      <el-button type="success" class="create_plan">创建计划:</el-button>
      <sl-table
        name="sl-table2"
        :tableData="work_plan_tableData"
        :tableKey="work_plan_tableKey"
      ></sl-table>
    </div>

    <!-- 保存/取消按钮 -->
    <div class="save_btn">
      <el-button type="success" class="save_btn" @click="save_editBid"
        >保存</el-button
      >
      <el-button class="cancel_btn">取消</el-button>
    </div>
  </div>
</template>

<style src="../../../../style/project/bid.css"></style>    

<script>
import bidHomeTable from "../../../../components/project/bid/bidHomeTable";
import bidMixin from "../../../../minxins/projectMixin/bidMixin";
export default {
  mixins: [bidMixin],
  components: {
    "sl-table": bidHomeTable,
  },
  data() {
    return {
      // 表单数据
      bid_add_data: {
        id: this.$route.params.id,
        name: "",
        area: "",
        kai_fa_name: "",
        begin_date: "",
        end_date: "",
        pay_money: 1,
      },

      // ========================
      options_deposit_payment: [
        {
          value: "选项1",
          label: "1",
        },
        {
          value: "选项2",
          label: "2",
        },
      ],
      options_project_area: [
        {
          value: "选项1",
          label: "1",
        },
        {
          value: "选项2",
          label: "2",
        },
      ],
      option_create_date: [
        {
          value: "选项1",
          label: "1",
        },
        {
          value: "选项2",
          label: "2",
        },
      ],
      option_end_date: [
        {
          value: "选项1",
          label: "1",
        },
        {
          value: "选项2",
          label: "2",
        },
      ],
      // ========================
      member_add_tableData: [{}, {}],
      member_add_tableKey: [
        { name: "序号", value: "id" },
        { name: "头像", value: "icon" },
        { name: "姓名", value: "name" },
        { name: "手机号", value: "tel" },
        { name: "部门", value: "department" },
        { name: "岗位", value: "post" },
        { name: "操作", value: "todo" },
      ],
      work_plan_tableData: [{}, {}],
      work_plan_tableKey: [
        { name: "序号", value: "id" },
        { name: "分项", value: "item" },
        { name: "描述", value: "description" },
        { name: "负责人", value: "member" },
        { name: "开始日期", value: "start_time" },
        { name: "结束日期", value: "end_time" },
        { name: "操作", value: "todo" },
      ],
    };
  },
  methods: {
    // 编辑对应ID投标
    getEditBid() {
      let bidId = this.$route.params.id;
      console.log(bidId);

      this.$projectApi.getEditBid(bidId).then((res) => {
        if (res.data.code == 200) {
          console.log(res.data.msg);
        }
      });
    },
    // 保存
    save_editBid() {
      //   // 回显

      this.$projectApi.editBid(this.bid_add_data).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          console.log(res.data.msg);
        } else {
          console.log(res.data.msg);
        }
      });

      this.$projectApi.getBit();
    },
  },
  mounted() {
    this.getEditBid();
  },
};
</script>

<style>
</style>